﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ServiceModel;

namespace hzWeb.GroupInfo
{
    public partial class GroupInfoUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                MeetingRoomServiceClient client = GetServiceClient();


                // sip: sip:test2@itfirst.com
                // userName: test2
                // password: Password01!
                // lyncServer: LYNC.ITFIRST.COM
                // domain: itfirst.com

                //  string meetingUrl = client.CreateFiveYearMeeting("test2", "Password01!", "LYNC.ITFIRST.COM", "itfirst.com", "sip:test2@itfirst.com");
               //  string meetingUrl = client.CreateFiveYearMeeting("test2", "Password01!", "LYNC.ITFIRST.COM", "itfirst.com", "sip:test2@itfirst.com");
               //  Label1.Text = meetingUrl;
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message + "</br>" + ex.StackTrace;
            }
        }


        private MeetingRoomServiceClient GetServiceClient()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            // I think most (or all) of these are defaults--I just copied them from app.config:
            binding.SendTimeout = TimeSpan.FromMinutes(1);
            binding.OpenTimeout = TimeSpan.FromMinutes(1);
            binding.CloseTimeout = TimeSpan.FromMinutes(1);
            binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
            binding.AllowCookies = false;
            binding.BypassProxyOnLocal = false;
            binding.MessageEncoding = WSMessageEncoding.Text;
            binding.TextEncoding = System.Text.Encoding.UTF8;
            binding.TransferMode = TransferMode.Buffered;
            binding.UseDefaultWebProxy = true;

            return new MeetingRoomServiceClient(binding, new EndpointAddress("http://vdi.itfirst.com:8888/MeetingRoomService.svc"));

        }
    }
}
